#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0;
        int right = height.size() - 1;

        int MaxWater = 0;

        while (left < right)
        {
            //int max = height[left]>height[right]?height[left]:height[right];
            int min = height[left] > height[right] ? height[right] : height[left];
            int gap = right - left;
            int maxArea = min * gap;
            if (maxArea > MaxWater)
                MaxWater = maxArea;
            if (height[left] < height[right])
                left++;
            else
                right--;
        }
        return MaxWater;
    }
};